<?php
/**
 * Notes:
 * User: LiaoHong
 * Date: 2025/10/20
 * Time: 9:02
 **/


namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Http\Requests\User\PermissionRequest;
use App\Http\Requests\User\RoleRequest;
use App\Services\User\RoleService;

class RoleController extends Controller
{
    /** @var RoleService */
    private RoleService $roleService;

    public function __construct(RoleService $service)
    {
        $this->roleService = $service;
    }

    /**
     * @Notes:添加角色
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function add(RoleRequest $request)
    {
        $data = $request->input();
        return success($this->roleService->add($data));
    }

    /**
     * @Notes:获取单条菜单信息
     * @param RoleRequest $request
     * @author: Liao Hong
     * @Time: 2025/10/21   14:31
     * @Interface getRow
     */
    public function getRow(RoleRequest $request)
    {
        $data = $request->input();
        return success($this->roleService->getRow($data));
    }
    /**
     * @Notes:修改角色
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function update(RoleRequest $request)
    {
        $data = $request->input();
        return success($this->roleService->update($data));
    }
    /**
     * @Notes:删除角色
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function delete(RoleRequest $request)
    {
        $data = $request->input();
        return success($this->roleService->delete($data));
    }
    /**
     * @Notes:角色列表
     * @author: Liao Hong
     * @Time: 2025/10/20   9:30
     * @Interface add
     */
    public function list(RoleRequest $request)
    {
        $data = $request->input();
        return success($this->roleService->list($data));
    }

    /**
     * @Notes:获取角色所选的菜单
     * @param RoleRequest $request
     * @author: Liao Hong
     * @Time: 2025/10/22   15:12
     * @Interface roleMenuTreeselect
     */
    public function roleMenuTreeselect(RoleRequest $request)
    {
        $data = $request->input();
        return success($this->roleService->roleMenuTreeselect($data));

    }

}
